<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>添加用户</title>
</head>
<body>
            <div>
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">添加用户</h3>
                    </div>
                    <div class="form-horizontal">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="UserName" class="col-sm-2 control-label">用户名</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="UserName" placeholder="UserName">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="Password" class="col-sm-2 control-label">用户密码</label>
                                <div class="col-sm-10">
                                    <input type="password" class="form-control" id="Password" placeholder="Password">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="Sex" class="col-sm-2 control-label">性别</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="Sex" placeholder="Sex">
                                </div>
                            </div>
                        </div>
                        <div class="box-footer">
                            <button type="submit" class="btn btn-success btn-flat" onclick="addUser()">新增</button>
                        </div>
                    </div>
                </div>
            </div>
    <script>

        function addUser() {

            var user = {
                userName: $("#UserName").val(),
                password: $("#Password").val(),
                sex: $("#Sex").val()
            };
            $.ajax({
                type: 'post',
                url: "/user/addUser",
                //headers: {'Content-type': 'application/json;charset=UTF-8'},
                contentType: 'application/json;charset=UTF-8',
                dataType: "json",
                data: JSON.stringify(user),
                success: function (result) {
                    alert("添加成功");
                    window.location.href = "/admin/user/selectUser"
                },
                error: function (result) {
                    alert("失败了");
                }
            })
        }

    </script>
</div>
</body>
</html>